import request from '@/utils/request'
const Auth = '/system/auth'
const api = {
  login: `${Auth}/login`,
  logout: `${Auth}/logout`,
  forgePassword: `${Auth}/forge-password`,
  register: `${Auth}/emailRegister`,
  sendEmail: `${Auth}/send/email`,
}

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
export function login(parameter) {
  return request({
    url: api.login,
    method: 'post',
    data: parameter,
  })
}

export function getEmailCaptcha(parameter) {
  return request({
    url: api.sendEmail,
    method: 'post',
    data: parameter,
  })
}

export function logout() {
  return request({
    url: api.logout,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function register(parameter) {
  return request({
    url: api.register,
    method: 'post',
    data: parameter,
  })
}
